var resultTable;
function getRobotResultList() {
    if (typeof resultTable !== 'undefined') {
        resultTable.fnPageChange('first');
        return;
    }
    resultTable = $("#robotResultList").DataTable({
        "sAjaxSource": _path + "/robotResult/list",     //服务端
        "fnServerParams": function (aoData) {               //ajax请求参数
            aoData.push(
                { "name": "name", "value": $("#name").val()},
                { "name": "status", "value": $("#status").val()},
                { "name": "fromDate", "value": $("#fromDate").val() },
                { "name": "toDate", "value": $("#toDate").val() }
            );
        },
        "fnServerData": function(sUrl, aoData, fnCallback) {
            var data = new Array();
            for(var i in aoData)
                data.push(aoData[i].name + '=' + aoData[i].value);
            $.ajax( {
                "type": "POST",
                "url": sUrl,
                "dataType": "json",
                "data": data.join('&'),
                "success": function(resp) {
                    fnCallback(resp);
                }
            });
        },
        "sServerMethod": "POST",    //请求方式
        "sAjaxDataProp": "dataList",//后台返回数据名
        "aoColumns": [
            { "sTitle": "站点名称", "sWidth": "6%", "mData": "name" },
            { "sTitle": "链接标题", "sWidth": "6%", "mData": "title" },
            { "sTitle": "链接地址", "sWidth": "6%", 
                "mData": function (data) {
               	    var html = new Array();
                    var href = data.link;
               	    html.push('<a href="'+href+'" target="_blank">'+href+'</a>');
                    return html.join('');
               }
            },
            { "sTitle": "采集状态", "sWidth": "6%", "mData": "statusname" },
            { "sTitle": "操作", "sWidth": "10%",
                "mData": function (data) {
                	 var html = new Array();
                     if (data.status == "1") {
                    	 html.push('<a href="javascript:void(0);" onclick="showDetail(\'' + data.id + '\',\'' +escape(data.title) + '\');">[查看详情]</a>');
                     }
                     return html.join('');
                }
            },
        ]
    });
}

function showDetail(id,title){
	App.ajax(_path + "/robotResult/showDetail", "id=" + id, function (data) {
		$("#detailTitleDiv").html(unescape(title));
		$("#detailContentDiv").html(data.content);
		$('#ajax-modal').modal('show');
	});	
}